//
//  HMSportMapModeController.m
//  HMSport
//
//  Created by apple on 2017/4/24.
//  Copyright © 2017年 itheima. All rights reserved.
//

#import "HMSportMapModeController.h"

@interface HMSportMapModeController ()
//选中地图类型block
@property (nonatomic, copy) void(^selectBlock)(HMMapType mapType);
//地图类型按钮集合
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *mapModeBtns;

@end

@implementation HMSportMapModeController


- (instancetype)initWithSelectBlock:(void (^)(HMMapType))selectBlock
{
    self = [super init];
    if (self) {
        
        self.selectBlock = selectBlock;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    //设置当前的地图类型
    UIButton *btn = self.mapModeBtns[self.mapType];
    btn.selected = YES;
}

- (IBAction)clickMapModeBtn:(UIButton *)sender {
    
    for (UIButton *btn in self.mapModeBtns) {
        
        //判断当前选中状态
        if (!sender.selected) {
            
            if (self.selectBlock) {
                
                //执行选中Block  传递数据给trackVc
                self.selectBlock(sender.tag);
            }
        }
        //设置选中
        btn.selected = (btn == sender) ? YES : NO;
    }
    
}


@end
